﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Forms;
using EqRepair.Code.Classes;
using EqRepair.Code.Data;

namespace EqRepair.Web
{
	public partial class Users : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{

		}

		protected void ButtonAdd_Click(object sender, EventArgs e)
		{
			using (var db = new DataClasses2DataContext())
			{
				AccessData.AddUser(TextBoxL.Text,TextBoxP.Text,Int32.Parse(DropDownListCh.SelectedItem.Value), Int32.Parse(DropRole.SelectedValue),TextBoxN.Text);
				
				db.SubmitChanges();
				GridView1.DataBind();
			}
		}

		protected void LinqDataSource1_Deleting(object sender, LinqDataSourceDeleteEventArgs e)
		{
			if(((Employee)e.OriginalObject).Id==33)
			{
				MessageBox.Show("Нельзя удалить системного пользователя.", "Внимание.", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
				e.Cancel = true;
			}
		}
	}
}
